Efficiency ของ แม่แบบ:Show data

In this template system each template contains various properties of a single entity, as opposed to the other common system, where a template contains one property (e.g. population or area) of many entities. Although that other system can be convenient if updates of a property for all these entities become available together, in the case of large-scale use of data on one page that other system can be problematic due to its inefficiency. This is because of the following:

  • There are often more entities than properties, and page counts (or in the case of #switch, average page counts) are proportional to the number of data items in the data template (if they are stored in a linear way, not in a tree, and not stored as unnamed parameters).
  • In the case of large-scale use of data on one page there are usually one or more tables, where an entity forms a row and a property a column, because there are often more entities than properties, and because this way the sorting feature allows sorting entities based on a property. In this template system this allows producing a row with only one call of the data template, making the count not grow faster than proportional to the average number of data items stored per data template, times the number of entities in the table.

The include part of the data template of an entity does not contain a long list of its sub-entities or their properties, because that would make this method inefficient too.

  1. It may seem odd, but a template cannot retrieve its own name (PAGENAME only provides this on the template page itself), and even if it could, a string operation would be needed to remove "Data ". Putting the name of the entity in the data template removes the need to supply it as a parameter when the data template is called (in the cases that it would need this name).
  2. See the first two rows of the first table in m:Help:Array#Summary of counts for template limits.

Until here the documentation is automatically generated by Template:Show data.

คู่มือการใช้งานแม่แบบ[สร้าง]
ผู้เขียนสามารถทำการทดลองได้ที่กระบะทราย (สร้าง | คัดลอก) และชุดทดสอบ (สร้าง) ของแม่แบบนี้
โปรดเพิ่มหมวดหมู่ไปที่หน้าย่อย /doc หน้าย่อยของแม่แบบนี้